﻿<!--revision $Id$-->
<UserControl x:Class="OpenWPFChart.Helpers.ChartScaleControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="clr-namespace:OpenWPFChart.Helpers"
    xmlns:parts="clr-namespace:OpenWPFChart.Parts;assembly=OpenWPFChart.Parts"
	Name="chartScaleControl"
    >

	<UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="../DialogStyle.xaml"/>
			</ResourceDictionary.MergedDictionaries>

			<local:ChartScaleGroupTypeToClassDescriptionConverter x:Key="scaleGroupToString"/>
			
			<!-- Scale Group ComboBox Item Template -->
			<DataTemplate x:Key="cbxScaleGroupItemTemplate">
				<TextBlock Text="{Binding Converter={StaticResource scaleGroupToString}}"/>
			</DataTemplate>
			
			<!--Chart Scale Templates-->
			<DataTemplate DataType="{x:Type parts:ChartLinearScale}">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition/>
					</Grid.ColumnDefinitions>

					<!-- Scale Group row -->
					<Label Target="{Binding ElementName=cbxScaleGroup}">Scale Group</Label>
					<ComboBox Grid.Column="1" Name="cbxScaleGroup"
						ItemsSource="{Binding ElementName=chartScaleControl, Path=ChartScaleGroup}"
						ItemTemplate="{StaticResource cbxScaleGroupItemTemplate}"
						SelectedItem="{Binding ElementName=chartScaleControl, Path=ChartScaleType}"/>

					<!-- Start row -->
					<Label Grid.Row="1" Target="{Binding ElementName=txtStart}">Start</Label>
					<TextBox Grid.Row="1" Grid.Column="1" Name="txtStart"
						Text="{Binding Path=Start, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>

					<!-- Stop row -->
					<Label Grid.Row="2" Target="{Binding ElementName=txtStop}">Stop</Label>
					<TextBox Grid.Row="2" Grid.Column="1" Name="txtStop"
						Text="{Binding Path=Stop, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>

					<!-- Scale row -->
					<Label Grid.Row="3" Target="{Binding ElementName=txtScale}">Scale</Label>
					<TextBox Grid.Row="3" Grid.Column="1" Name="txtScale"
						Text="{Binding Path=Scale, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>
				</Grid>
			</DataTemplate>

			<DataTemplate DataType="{x:Type parts:ChartLogarithmicScale}">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition/>
					</Grid.ColumnDefinitions>

					<!-- Scale Group row -->
					<Label Target="{Binding ElementName=cbxScaleGroup}">Scale Group</Label>
					<ComboBox Grid.Column="1" Name="cbxScaleGroup"
						ItemsSource="{Binding ElementName=chartScaleControl, Path=ChartScaleGroup}"
						ItemTemplate="{StaticResource cbxScaleGroupItemTemplate}"
						SelectedItem="{Binding ElementName=chartScaleControl, Path=ChartScaleType}"/>

					<!-- Start row -->
					<Label Grid.Row="1" Target="{Binding ElementName=txtStart}">Start</Label>
					<TextBox Grid.Row="1" Grid.Column="1" Name="txtStart"
						Text="{Binding Path=Start, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>

					<!-- Stop row -->
					<Label Grid.Row="2" Target="{Binding ElementName=txtStop}">Stop</Label>
					<TextBox Grid.Row="2" Grid.Column="1" Name="txtStop"
						Text="{Binding Path=Stop, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>

					<!-- Scale row -->
					<Label Grid.Row="3" Target="{Binding ElementName=txtScale}">Scale</Label>
					<TextBox Grid.Row="3" Grid.Column="1" Name="txtScale"
						Text="{Binding Path=Scale, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>
				</Grid>
			</DataTemplate>

			<DataTemplate DataType="{x:Type parts:ChartDateTimeScale}">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition/>
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition/>
					</Grid.ColumnDefinitions>

					<!-- Scale Group row -->
					<Label Target="{Binding ElementName=cbxScaleGroup}">Scale Group</Label>
					<ComboBox Grid.Column="1" Name="cbxScaleGroup"
						ItemsSource="{Binding ElementName=chartScaleControl, Path=ChartScaleGroup}"
						ItemTemplate="{StaticResource cbxScaleGroupItemTemplate}"
						SelectedItem="{Binding ElementName=chartScaleControl, Path=ChartScaleType}"/>

					<!-- Start row -->
					<Label Grid.Row="1" Target="{Binding ElementName=txtStart}">Start</Label>
					<TextBox Grid.Row="1" Grid.Column="1" Name="txtStart"
						Text="{Binding Path=Start, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>

					<!-- Stop row -->
					<Label Grid.Row="2" Target="{Binding ElementName=txtStop}">Stop</Label>
					<TextBox Grid.Row="2" Grid.Column="1" Name="txtStop"
						Text="{Binding Path=Stop, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>

					<!-- Scale row -->
					<Label Grid.Row="3" Target="{Binding ElementName=txtScale}">Scale</Label>
					<TextBox Grid.Row="3" Grid.Column="1" Name="txtScale"
						Text="{Binding Path=Scale, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>
				</Grid>
			</DataTemplate>

			<DataTemplate DataType="{x:Type parts:ChartSeriesScale}">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition/>
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition/>
					</Grid.ColumnDefinitions>

					<!-- Scale Group row -->
					<Label Target="{Binding ElementName=cbxScaleGroup}">Scale Group</Label>
					<ComboBox Grid.Column="1" Name="cbxScaleGroup"
						ItemsSource="{Binding ElementName=chartScaleControl, Path=ChartScaleGroup}"
						ItemTemplate="{StaticResource cbxScaleGroupItemTemplate}"
						SelectedItem="{Binding ElementName=chartScaleControl, Path=ChartScaleType}"/>

					<!-- Start row -->
					<Label Grid.Row="1" Target="{Binding ElementName=cbxStart}">Start</Label>
					<ComboBox Grid.Row="1" Grid.Column="1" Name="cbxStart"
						ItemsSource="{Binding Path=Series}"
						SelectedItem="{Binding Path=Start}"/>

					<!-- Stop row -->
					<Label Grid.Row="2" Target="{Binding ElementName=cbxStop}">Stop</Label>
					<ComboBox Grid.Row="2" Grid.Column="1" Name="cbxStop"
						ItemsSource="{Binding Path=Series}"
						SelectedItem="{Binding Path=Stop}"/>

					<!-- Scale row -->
					<Label Grid.Row="3" Target="{Binding ElementName=txtScale}">Scale</Label>
					<TextBox Grid.Row="3" Grid.Column="1" Name="txtScale"
						Text="{Binding Path=Scale, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>
				</Grid>
			</DataTemplate>
		</ResourceDictionary>
	</UserControl.Resources>

	<ContentControl Content="{Binding ElementName=chartScaleControl, Path=ChartScale}"/>
</UserControl>
